package com.mentaleye.dal.dao.mybatis;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.mentaleye.dal.dao.OaClassRelationDao;
import com.mentaleye.dal.model.OaClassRelation;
import com.mentaleye.dal.model.OaClassRelationExample;
import com.mentaleye.dal.model.OaClassRelationExample.Criteria;
import com.mentaleye.dal.model.OaClassRelationKey;
import com.mentaleye.dal.service.OaClassRelationMapper;

@Repository
public class OaClassRelationDaoImpl extends BaseDao implements OaClassRelationDao{

	@Autowired private OaClassRelationMapper oaClassRelationMapper;
	
	@Override
	public boolean addOaClassRelation(OaClassRelation oaClassRelation) {
		return getResultByInt(oaClassRelationMapper.insert(oaClassRelation));
	}
	
	@Override
	public boolean addOaClassRelationList(List<OaClassRelation> list){
		return getResultByInt(oaClassRelationMapper.insertOaClassRelationList(list));
	}

	@Override
	public boolean updateOaClassRelation(OaClassRelation oaClassRelation) {
		return getResultByInt(oaClassRelationMapper.updateByPrimaryKeySelective(oaClassRelation));
	}
	
	@Override
	public boolean updateOaClassRelationList(Map<String, Object> map){
		return getResultByInt(oaClassRelationMapper.updateOaClassRelationList(map));
	}

	@Override
	public boolean deleteOaClassRelation(OaClassRelationKey key) {
		return getResultByInt(oaClassRelationMapper.deleteByPrimaryKey(key));
	}

	@Override
	public List<OaClassRelation> queryOaClassRelationById(List<Integer> ids){
		OaClassRelationExample example = new OaClassRelationExample();
		Criteria criteria = example.createCriteria();
		criteria.andOaclassIdIn(ids);
		return oaClassRelationMapper.selectByExample(example);
	}
	
	public List<OaClassRelation> queryOaClassRelationByPersonId(List<Integer> ids){
		OaClassRelationExample example = new OaClassRelationExample();
		Criteria criteria = example.createCriteria();
		criteria.andPersonIdIn(ids);
		return oaClassRelationMapper.selectByExample(example);
	}
	
	@Override
	public OaClassRelation queryOaClassRelationByKey(OaClassRelationKey key){
		return oaClassRelationMapper.selectByPrimaryKey(key);
	}
	
	@Override
	public List<OaClassRelation> queryOaClassRelationByIdAndPersonType(OaClassRelation oaClassRelation){
		return oaClassRelationMapper.selectPersonIdByIdAndPersonType(oaClassRelation);
	}
	
	@Override
	public OaClassRelation selectClassIdByPersonId(int personId){
		return oaClassRelationMapper.selectClassIdByPersonId(personId);
	}

	@Override
	public List<Map<String, Object>> queryClassCountByPerson(OaClassRelation oaClassRelation) {
		oaClassRelation.setPersonType(24);
		return oaClassRelationMapper.selectClassCountByPerson(oaClassRelation);
	}
	public  List<OaClassRelation> queryOaclassRelation(OaClassRelationExample example){
		return oaClassRelationMapper.selectByExample(example);
	}

	@Override
	public List<OaClassRelation> queryStudentByClassId(Integer oaclassId) {
		return oaClassRelationMapper.selectStudentByClassId(oaclassId);
	}

	public List<Map<String, Object>> selectNotClassStudent(){
		return oaClassRelationMapper.selectNotClassStudent();
	}

	@Override
	public boolean deleteByExample(OaClassRelationExample example) {
		boolean isSuccess=false;
		if(this.oaClassRelationMapper.deleteByExample(example)>0)
		{
			isSuccess=true;
		}
		return isSuccess;
	}

	@Override
	public List<Map<String, Object>> getListByMap(Map<String, Object> map) {
		return this.oaClassRelationMapper.getListByMap(map);
	}

	@Override
	public boolean updateOaClassRelationByExampleSelective(OaClassRelation record,OaClassRelationExample example) {
		boolean isSuccess=false;
		if(this.oaClassRelationMapper.updateByExampleSelective(record, example)>0)
		{
			isSuccess=true;
		}
		return isSuccess;
	}
}
